<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>设备研制方案</el-breadcrumb-item>
      <el-breadcrumb-item>研制方案管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>单据列表</span>
      </div>
      <el-button type="primary" @click="add">新增</el-button>
      <!-- 用户列表区域-->
      <el-table :data="equipmentlist" border stripe
                :header-cell-style="{'text-align':'center'}"
                :cell-style="{'text-align':'center'}">
        <el-table-column prop="ticketId" label="单据编号" ></el-table-column>
        <el-table-column prop="planId" label="方案编码"></el-table-column>
        <el-table-column prop="equipmentName" label="设备名称"></el-table-column>
        <el-table-column prop="tbName" label="填报人"></el-table-column>
        <el-table-column prop="tbDepartment" label="填报部门"></el-table-column>
        <el-table-column prop="date" label="填报日期"></el-table-column>
        <el-table-column prop="fzName" label="负责人"></el-table-column>
        <el-table-column prop="fzDepartment" label="负责部门"></el-table-column>
        <el-table-column prop="state" label="状态"></el-table-column>
      </el-table>
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :total="total"
        :current-page="queryInfo.nowpage"
        :page-sizes="[1, 2, 5, 10]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      // 审核列表
      equipmentlist: [],
      // 总数
      total: 0,
      queryInfo: {
        // 当前页数
        nowpage: 1,
        // 当前每页显示多少条数据
        pagesize: 10,
        // 选择种类
        select: '',
        // 搜索内容
        searchContent: ''
      }
    }
  },
  created () {
    this.getEquipmentList()
  },
  methods: {
    add () {
      this.$router.push({ path: '/addEquipment' })
    },
    getEquipmentList () {
      this.$http.get('equipment-list', { params: this.queryInfo }).then(res=> {
        if (res.status !== 200) {
          return this.$message.error('获取审核列表失败!')
        }
        this.equipmentlist=[]
        for (var i = 1; i < res.data.length; i++) {
          this.equipmentlist.push(res.data[i])
        }
        this.total = res.data[0].number
      })
    },
    // 监听分页尺寸改变的事件
    handleSizeChange (newSize) {
      this.queryInfo.pagesize = newSize
      this.getEquipmentList()
    },
    // 监听当前页码值改变的事件
    handleCurrentChange (nowPage) {
      this.queryInfo.nowpage = nowPage
      this.getEquipmentList()
    }
  }
}
</script>
<style lang="less" scoped>
  .el-input {
    width: 500px;
  }
  .el-select {
    width: 110px;
  }
  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }
  .el-table {
    margin-top: 15px;
    font-size: 12px;
  }
  .el-pagination {
    margin-top: 15px;
  }
</style>
